<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/css/bootstrap.css">
    <link rel="stylesheet" href="/css/comment.css">
    <script src="/js/jquery.js"></script>
    <script src="/js/bootstrap.js"></script>
    <title>houseComment</title>
    <style>
        .top-buffer{
            margin-top: 40px;
        }
    </style>
</head>
<body>
<div class="container-lg mt-5">
    <div class="card border p-2" style="border-radius: 10px">
        <div class="card-header text-info  border-bottom border-info" style="background-color: white;border-radius: 10px">
            评论留言
        </div>
        <div class="card-body">
            <!--            输入框-->
            <div id="noteEdit">
                <textarea name="note" class="form-control" style="border-radius: 10px" id="commentForHouse" rows="3"></textarea>
            </div>
            <!--提交列表-->
                <div class="row top-buffer">
                    <div class="col-md-4"></div>
                    <div class="list-inline-item col-md-4">
                        <a class="btn  btn-outline-info" style="width: 100%;height: 100%" th:onclick="addHouseComment([[${session.Onehouse.houseid}]])">发送</a>
                    </div>
                </div>

            <!--留言列表-->
            <div class=" container-fluid mt-5 border p-2" style="border-top: #17a2b8 solid 2px !important;">
                <div class="p-1 comments" th:each="c,i : ${session.houseCommentPage.getList()}">
                    <div class="container comment  m-1 p-0">
                        <a class="me-a avatar p-0 m-0">
                            <img class="w-100 h-100 rounded-circle" th:src="${session.houseCommentUsers.getList().get(i.index).userimage}"
                                 alt="">
                        </a>
                        <div class=" ml-3 border-left ">
                            <div class="container">
                                <a class="author">
                                    <div class="col-md-2"></div>
                                    <span th:text="${session.houseCommentUsers.getList().get(i.index).username}"></span>
                                    <span class="summary-text small" th:text="${c.commentdate}"></span>
                                </a>
                            </div>
                            <div class="messageText ml-2 container m-2" th:text="${c.commentdescription}"></div>
                            <!--  评论回复-->
                        </div>


                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    function addHouseComment(houseid) {
        var comment = document.getElementById('commentForHouse').value;
        $.ajax({
            url:'/comment/addNewComment',
            type:'GET',
            data:{"houseComment":comment,"houseid":houseid},
            success:function (html) {
                $('#houseCommentInfo').html(html);
                loadComments();
            }
        })
    }
</script>
</html>